﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.生产下单;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.销售台账.service
{
    public class 销售台账Service
    {
        public static List<OrderStatusSaleIndexDTO> get筛选销售台账(String dateTimeStr, String shopId)
        {
            return
                FunctionHelper.JsonDeserialization<List<OrderStatusSaleIndexDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getOrderSaleStatusIndexPageable?shopId=" + shopId + "&dateTimeStr=" + dateTimeStr
                            + "&pageStart=" + 0 + "&pageSize=" + 1000
                        )
                    );
        }
        /// <summary>
        /// 美国坚山销售日记账一览
        /// </summary>
        /// <param name="dateTimeStr"></param>
        /// <param name="shopId"></param>
        /// <returns></returns>
        public static List<OrderStatusSaleIndexDTO> getUSKashiyamaOrderStatusIndexPageable(String dateTimeStr, String shopId)
        {
            return
                FunctionHelper.JsonDeserialization<List<OrderStatusSaleIndexDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getUSKashiyamaOrderStatusIndexPageable?shopId=" + shopId + "&dateTimeStr=" + dateTimeStr
                            + "&pageStart=" + 0 + "&pageSize=" + 1000
                        )
                    );
        }
        /// <summary>
        /// 坚山xml订单的销售日记账
        /// </summary>
        /// <param name="dateTimeStr"></param>
        /// <returns></returns>
        public static List<KashiyamaOrderStatusSaleIndexFacadeDTO> getKALatestXmlOrderData(String dateTimeStr)
        {
            return
                FunctionHelper.JsonDeserialization<List<KashiyamaOrderStatusSaleIndexFacadeDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/kashiyamaUS/getKALatestXmlOrderData?dateTimeStr=" + dateTimeStr
                        )
                    );
        }
        public static List<OrderStatusSaleIndexDTO> get待确认一览(String startDateTimeStr, String endDateTimeStr, String shopId)
        {
            return
                FunctionHelper.JsonDeserialization<List<OrderStatusSaleIndexDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getOrderStatusIndexToBeConfirmTruePageable?shopId=" + shopId + "&startDateTimeStr=" + startDateTimeStr
                        + "&endDateTimeStr=" + endDateTimeStr + "&pageStart=" + 0 + "&pageSize=" + 1000
                        )
                    );
        }
        public static void post确认销售台账(List<OrderDailyConfirmDTO> OrderDailyConfirmDTOs)
        {
            RestCall.PostHttp(
                URL.接口url + "/pmc/saleInitWIPBatch",
                FunctionHelper.JsonSerialization(OrderDailyConfirmDTOs)
                );
        }
        
        /// <summary>
        /// 按照生产号查询坚山xml导入订单导入日志
        /// </summary>
        /// <param name="productNo"></param>
        /// <returns></returns>
        public static List<KashiyamaJyutyuDTO> getKashiyamaJyutyuRecordsByProductNo(String productNo)
        {
            try
            {
                return
                FunctionHelper.JsonDeserialization<List<KashiyamaJyutyuDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/kashiyamaUS/getKashiyamaJyutyuRecordsByProductNo?productNo=" + productNo
                        )
                    );
            }
            catch (Exception ex)
            {
                Console.WriteLine("坚山xml订单纸报错");
                Console.WriteLine(ex.Message);
                return new List<KashiyamaJyutyuDTO>();
            }
        }

        /// <summary>
        /// 坚山异常接口，同步订单一览
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static String syncOrderStatusIndex(String orderId)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/kashiyamaUS/syncOrderStatusIndex?orderId=" + orderId
                );
        }
    }
    public class OrderStatusSaleIndexDTO
    {
        public String orderId { get; set; }
        //客户
        public String consignee { get; set; }  //  收件人
        public String customerId { get; set; }
        public String customerName { get; set; }
        public String mobile { get; set; }
        public String addressId { get; set; }
        public String addressProvince { get; set; }//省
        public String addressCity { get; set; }//市
        public String addressDistrict { get; set; }//区
        public String addressDetail { get; set; }//详细地址
        public String zipCode { get; set; }//邮编
        //面料
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String composition { get; set; }//面料成分
        //款式
        public String styleSizeCd { get; set; }//尺码
        public String styleNameCn { get; set; }//款式名称
        public String refStyleId { get; set; }  //  标准款id
        //订单
        public String orderNo { get; set; } //  订单号
        public Double quantity { get; set; }    //  订单数量
        public DateTime orderDate { get; set; }//订单时间
        //订单状态
        public String orderStatus { get; set; }
        //店铺
        public String shopId { get; set; }
        public String shopName { get; set; }
        //销售确认
        public Boolean urgent { get; set; } //  是否加急
        public Boolean toBeConfirm { get; set; }  //  待确认
        public Boolean garmentModify { get; set; }//  成衣修改
        public String garmentBarcode { get; set; }//  成衣条码
        //价格
        public Double price { get; set; }//单价
        public Double totalPrice { get; set; }//总价

        public OrderStatusSaleIndexDTO()
        {

        }
    }

    /// <summary>
    /// 销售台账确认提交DTO
    /// </summary>
    public class OrderDailyConfirmDTO
    {
        public String orderId { get; set; }
        public Boolean urgent { get; set; } //  是否加急
        public Boolean toBeConfirm { get; set; }    //  待确认
        public Boolean garmentModify { get; set; }  //  成衣修改
        public String garmentBarcode { get; set; } //  成衣条码
        public OrderDailyConfirmDTO()
        {

        }
        public OrderDailyConfirmDTO(OrderStatusSaleIndexDTO dto)
        {
            this.orderId = dto.orderId;
            this.urgent = dto.urgent;
            this.toBeConfirm = dto.toBeConfirm;
            this.garmentModify = dto.garmentModify;
            this.garmentBarcode = dto.garmentBarcode;
        }
        public OrderDailyConfirmDTO(KashiyamaOrderStatusSaleIndexFacade页面VO dto)
        {
            this.orderId = dto.orderId;
            this.urgent = dto.urgent;
            this.toBeConfirm = dto.toBeConfirm;
            this.garmentModify = dto.garmentModify;
            this.garmentBarcode = dto.garmentBarcode;
        }
        public OrderDailyConfirmDTO(销售日记账预览VO dto)
        {
            this.orderId = dto.orderId;
            this.urgent = dto.urgent;
            this.toBeConfirm = dto.toBeConfirm;
            this.garmentModify = dto.garmentModify;
            this.garmentBarcode = dto.garmentBarcode;
        }

    }
    /// <summary>
    /// 坚山xml看板返回KashiyamaOrderStatusSaleIndexFacadeDTO
    /// </summary>
    public class KashiyamaOrderStatusSaleIndexFacadeDTO
    {
        public String productNo { get; set; }
        public KashiyamaJyutyuDTO kashiyamaJyutyuDTO { get; set; } = new KashiyamaJyutyuDTO();
        public OrderStatusSaleIndexDTO orderStatusSaleIndexDTO { get; set; } = new OrderStatusSaleIndexDTO();
        public KashiyamaOrderStatusSaleIndexFacadeDTO()
        {

        }
    }
    /// <summary>
    /// 坚山xml数据KashiyamaJyutyuDTO
    /// </summary>
    public class KashiyamaJyutyuDTO
    {
        public String id { get; set; }
        public String productNo { get; set; }   //  坚山xml数据的制造番号
        public String oyaProductNo { get; set; }    //  制造母番号
        public String seisanSosikiCd { get; set; }  //  组织编码
        public String item { get; set; }    //  项目
        public String brand { get; set; }   //  品牌
        public String period { get; set; }  //  季别
        public String itemNumber { get; set; }  //  品番
        public DateTime orderDate { get; set; }   //  下单日
        public DateTime inputDt { get; set; } //  订单系统实际获取订单的日期（※截至21:00以后的订单都归到次日）
        public DateTime kojyoShukaDt { get; set; }    // 出厂日
        public DateTime deliDateArrival { get; set; }     //  交付日
        public String custKana { get; set; }    //  客户姓名
        public String kijiNo { get; set; }  //  面料号
        public String kijiColor { get; set; }   //  面料颜色
        public String itemType { get; set; }    //  袖长:用于判断长袖还是短袖
        public String companyCd { get; set; }   //  公司编码
        public String productYear { get; set; }     //  生产年份
        public String kijiBrand { get; set; }   //  面料品牌
        public String txPeriod { get; set; }    //  面料年季
        public String szCd  { get; set; }   //  尺寸
        public String katabanPtnCd { get; set; }    //  款式
        public DateTime createDate { get; set; }
        public KashiyamaJyutyuDTO()
        {

        }
    }


}
